package com.cn.wanxi.util;

import com.cn.wanxi.model.UserModel;

import java.math.BigDecimal;

public class Tool {
    /**
     * 将字符串转换为整型，如果转换出错，则返回-1
     *
     * @param value
     * @return
     */
    public static Integer stringToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {

        }
        return -1;
    }
    public static Integer pageToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {

        }
        return 1;
    }
    public static Integer limitToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {

        }
        return 10;
    }
    public static BigDecimal stringToBD(String value) {
        try {
            return new BigDecimal(value);
        } catch (Exception e) {

        }
        return null;
    }

    public static String nullToString(String value) {

        return value == null ? "" : value;

    }
}
